const Mock = require('mockjs');

const List = [];
const count = 103;

for (let i = 0; i < count; i++) {
    List.push(Mock.mock({
        'adminAccount': '@word(3,7)',
        'adminEmail': '@email',
        'adminId': '@increment()',
        'adminPassword': '@string(6,12)',
        'adminName': '@cname()',
        'adminSex|1': [0, 1],
        'adminPhone': '13@natural(100000000,999999999)',
        'adminStatus|1': [100, 200],
        'adminRoleId': '@natural(1,7)',
        'role': {
            'roleId': '@natural(1,7)',
            'roleName': '@cword(2,3)管理员'
        },
        'emailCode': '@integer(4,4)',
        'emailCodeTime': '@date("yyyy-MM-dd hh:mm:ss")',
        'phoneCode': '@integer(4,4)',
        'phoneCodeTime': '@date("yyyy-MM-dd hh:mm:ss")',
        'createdTime': '@date("yyyy-MM-dd hh:mm:ss")'
    }));
}

module.exports = [
    {
        url: '/vue-admin-template/admin/search',
        type: 'post',
        response: config => {
            const { page = 1, limit = 10 } = config.body;
            const pageList = List.filter((item, index) => index < limit * page && index >= limit * (page - 1));

            return {
                code: 200,
                data: {
                    total: List.length,
                    items: pageList
                }
            };
        }
    },

    {
        url: '/vue-admin-template/admin/insert',
        type: 'post',
        response: _ => {
            return {
                code: 200,
                message: '成功',
                success: true
            };
        }
    },

    {
        url: '/vue-admin-template/article/update',
        type: 'post',
        response: _ => {
            return {
                code: 200,
                data: 'success'
            };
        }
    }
];

